import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:icooker/providers/main_provider.dart';
import 'package:provider/provider.dart';

/// Main界面底部导航
class MainBottombar extends StatelessWidget {
  MainBottombar({Key? key}) : super(key: key);

  List<Tab> tabs = [
    Tab(
      icon: Icon(FontAwesome.home),
      text: "首页",
    ),
    Tab(
      icon: Icon(FontAwesome.gift),
      text: "食秀",
    ),
    Tab(
      icon: Icon(FontAwesome.smile_o),
      text: "食杰",
    ),
    Tab(
      icon: Icon(FontAwesome.question_circle_o),
      text: "点评",
    ),
    Tab(
      icon: Icon(FontAwesome.github),
      text: "我的",
    )
  ];

  @override
  Widget build(BuildContext context) {
    var provider = Provider.of<MainProvider>(context);
    return BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: provider.currentIndex,
        selectedItemColor: Theme.of(context).primaryColor,
        onTap: (index) {
          provider.scroll2Page(index);
        },
        unselectedItemColor: Colors.grey,
        items: tabs
            .map((e) =>
                BottomNavigationBarItem(icon: e.icon!, title: Text(e.text!)))
            .toList());
  }
}
